import {ProColumns, ProTable} from '@ant-design/pro-components';
import { Modal } from 'antd';
import React from 'react';

export type props = {
  columns: ProColumns<API.InterfaceInfo>[] ;
  onCancel: () => void;
  onSubmit: (values: API.InterfaceInfo) => Promise<void>;
  visible: boolean;
};

const CreateForm: React.FC<props> = (props: props) => {
  const { onCancel, onSubmit, visible, columns } = props;
  return (
    <Modal onCancel={() => onCancel?.()} visible={visible} footer={null}>
      <ProTable
        type="form"
        columns={columns}
        onSubmit={async (value) => {
          onSubmit?.(value);
        }}
      />
    </Modal>
  );
};

export default CreateForm;
